# ntpdate

# Builds from https://github.com/puppylinux-woof-CE/petbuilds

. ../func
. ../build.conf

URL=http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-dev/
PKG=ntpdate
SRC_PKG=ntp-dev
VER=4.3.77
COMP=tar.gz
DESC="ntpdate is a web centric time synchronisation tool"
DEPS=
CAT=BuildingBlock
DESKTOP=
BUILD=
CWD=$(pwd)
[ -z "$MWD" ] && MWD=$(dirname $CWD)	
[ -z "$BUILD" ] && BUILD=$DEF_BUILD
#[ -f "$DESKTOP" ] || DESKTOP=not
#[ -z "$DEPS" ] && DEPS=not	

ARCH=$(uname -m)
case $ARCH in
 *64) 	LIBDIR=$LIBCONF64 ;;
 arm*)	LIBDIR=$LIBCONFarm;;
 *) 	LIBDIR=$LIBCONF32 ;;
esac

build() {
	# since not X compiling forget build triplet
	cd ${SRC_PKG}-${VER}
	./configure --prefix=/usr \
				--localstatedir=/var \
				--sysconfdir=/etc \
				--libdir=/usr/${LIBDIR} \
				 --without-sntp
	[ "$?" -eq 0 ] || exit
	make
	cd -
}
	
package() {
	install -d -m 0755 ./${PKG}-${VER}-${ARCH}_${BUILD}/usr/bin
	EXE=`find ${SRC_PKG}-${VER} -type f -name 'ntpdate'`
	install -s -m 0755 $EXE ./${PKG}-${VER}-${ARCH}_${BUILD}/usr/bin
	# add this recipe
	install -d -m 0755 ./${PKG}_DEV-${VER}-${ARCH}_${BUILD}/usr/src/dev
	cat ${PKG}.petbuild > ./${PKG}_DEV-${VER}-${ARCH}_${BUILD}/usr/src/dev/$PKG-build-recipe
	if [ "$DESKTOP" ];then
		install -d -m 0755 ./${PKG}-${VER}-${ARCH}_${BUILD}/usr/share/applications
		cat $DESKTOP > ./${PKG}-${VER}-${ARCH}_${BUILD}/usr/share/applications/$DESKTOP
	fi
	# delete any icon cache or library cache
	find ./${PKG}-${VER}-${ARCH}_${BUILD} -type f -name '*cache' -delete
	[ -f ./pinstall.sh ] && install -m 0755 pinstall.sh ./${PKG}-${VER}-${ARCH}_${BUILD}/
	[ -f ./puninstall.sh ] && install -m 0755 puninstall.sh ./${PKG}-${VER}-${ARCH}_${BUILD}/
	for p in `ls|grep "\-${ARCH}"|grep -v "files$"` ; do
		case $p in
			*_DEV*) DESC="$PKG development"; DEPS=+${PKG} ;;
			*_DOC*) DESC="$PKG documentation"; DEPS=+${PKG} ;;
			*_NLS*) DESC="$PKG locales"; DEPS=+${PKG} ;;
		esac	
		echo "packaging $p"	
		dir2pet -x -s -w="$DESC" -d="$DEPS" -c=$CAT -p=${p} 2>&1 >/dev/null
		rm -r $p
		mv ${p}.pet ../0pets_out
	done
	rm -r ${SRC_PKG}-${VER}
	rm *.files 2>/dev/null
	echo "done!"
}

# main
retrieve ${SRC_PKG}-${VER}.${COMP}
extract ${SRC_PKG}-${VER}.${COMP}
build
package	
